home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 5
/
The 640 Meg Shareware Studio CD-ROM Volume V (Data Express)(1994).ISO
/
amiga
/
tempdemo.lha
/
ProgrammersInfo
/
DSKEL-NUAL.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-22
|
13KB
|
550 lines
//================================================================================
// PROGRAM: DSKEL-NUAL (New User Application Lister)
// VERSION: v1.5
//COMPILER: Lattice C v5.10b
// DATE: January 1, 1993
//================================================================================
/*
[DSKEL-NUAL v_._] New User Application Lister By The SkeletoN [__-__-__]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter Password:
[Return = Quit] [N = List New Users]
Enter Account Number or Handle:
# Handle Location 1st On LastOn Computer On
===--====================--====================-======--======--===========--==
45 New User 1 Location User 1 May 31 Jun 32 Type User 1 1
143 New User 2 Location User 2 Jun 22 Jul 23 Type User 2 2
===--====================--====================-======--======--===========--==
Total Users [ 233 ] New Users [ 23 ]
[Return = Continue List]
Enter Account Number or Handle:
*/
//**********************
//***** Includes *****
//**********************
#include <proto/all.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <tempest/headers.h>
//********************************
//***** Structures/Defines *****
//********************************
struct MyMessage
{
struct Message Msg;
struct User User;
char text[255];
char text1[255];
int car,Value,Data;
long LongValue;
int IntValue;
};
struct User User;
struct User User1;
struct SystemData SystemData;
struct MsgPort *MyPort = NULL;
struct MyMessage *msg;
#define DROP if(EXIT_FLAG) CloseStuff();
void CloseStuff();
void GetStr(char s[],int opt);
void getkey(char character[]);
void showfile(char mstring[]);
void input(char mstring[],int len);
int DOORIO();
int UserNumber(int );
void pl(char outstring[]);
void DisplayApp();
void WriteFile(char ostring[],char mstring[]);
void ZmodemDownload(char *);
void DownloadAll(void);
int EXIT_FLAG, DOOR_DATA, DOOR_CAR, DOOR_VALUE, DOOR_VALUE1 = 0,first = 0;
char DOOR_MSG [255],DOOR_MSG1[255],MyName[255],st[100];
char string1[255],string2[255],stringold[255];
char Name[255];
int fd,stat,NODE;
//******************
//***** Main *****
//******************
void main(int argc,char *argv[])
{
char string3[255],ch,
shit1[255],ListIt[255],Month1[50],Month2[50],Day1[50],Day2[50];
register int x,Test=0,y=0,Users,NewUsers;
int Result;
if(!DoorStart(argv[1])) { PutStr("[os2] Tempest Door\n"); exit(0); }
NODE=atoi(argv[1]);
//******************************
//***** Load Config.Data *****
//******************************
GetStr(string1,1);
strcat(string1,"Setup/SystemData.DATA");
fd=Open(string1,MODE_OLDFILE);
Read(fd,(char *)&SystemData, sizeof(struct SystemData));
Close(fd);
for(x=0;x<strlen(SystemData.SysopName);x++)
{
if(SystemData.SysopName[x] == '_')
SystemData.SysopName[x] = ' ';
}
//******************
//***** Code *****
//******************
pl("\f
[
DSKEL-NUAL v2.0
]
New User Application Lister By Michael Bockert
[
03-20-94
]\r\n");
pl("
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
if(SystemData.SysopCmdsPassword[0] != NULL)
{
pl("\r\nPassword: ");
setmem(string1,24,NULL);
do
{
getkey(string2);
if(string2[0] == 13)
break;
if(string2[0] == 8)
{
if(y>0)
{
y--;
string1[y] = NULL;
pl("\b \b");
}
}
else
{
if(y<21)
{
ch = string2[0];
string1[y] = ch;
pl(".");
y++;
}
}
}
while(1);
Result = stricmp(string1,SystemData.SysopCmdsPassword);
if(Result != 0)
CloseStuff();
}
y=0;
pl("\r\n\r\n");
//********************
//***** Prompt *****
//********************
PROMPT:
if(Test == 1)
pl("\r\n
[
Return
=
Continue List
]");
else
pl("
[
Return
=
Quit
] [
N
=
List New Users
]");
pl("\r\n
[
D = Download All
]
Enter Account Number or Handle
: ");
input(Name,31);
Name[0]=toupper(Name[0]);
if((Test != 1) && (Name[0] == NULL)) CloseStuff();
if(Name[0]=='N'&&Name[1]==NULL) goto NewUserSearch;
if(Name[0]=='D'&&Name[1]==NULL) { DownloadAll(); goto PROMPT; }
if((Name[0]=='Q')||(Name[0]=='N'))
{
if(Test) Close(fd);
CloseStuff();
}
if((Test == 1) && (Name[0] == NULL))
{
pl("\r\n");
goto NEXTFILE;
}
Result = atoi(Name);
if( (Result > 0) && (strlen(Name) < 4) )
Result = UserNumber(Result);
if(!(Result))
DisplayApp();
goto PROMPT;
//****************************
//***** New User Search *****
//****************************
NewUserSearch:
strcpy(shit1,"
===--====================--====================-======--======--===========--==\r\n");
GetStr(string3,1);
strcat(string3,"Accounts.data");
fd=Open(string3,MODE_OLDFILE);
pl("\f
# Handle Location 1st On LastOn Computer On\r\n");
pl(shit1);
Users=0; NewUsers=0;
NEXTFILE:
stat=Read(fd,&User1, sizeof(struct User));
if((stat<1)||(CTRLC()))
{
Close(fd);
pl(shit1);
sprintf(string3,"
Total Users
[
%3d
]
New Users
[
%d
]\r\n\r\n",Users,NewUsers);
pl(string3);
Test=0;
y=0;
goto PROMPT;
}
Users++;
if(User1.Status==2)
{
NewUsers++;
strcpy(string2,ctime(&User1.Time_First_Called));
strmid(string2,Month1,5,3);
strmid(string2,Day1,9,2);
strcpy(string2,ctime(&User1.Time_Last_Logoff));
strmid(string2,Month2,5,3);
strmid(string2,Day2,9,2);
sprintf(ListIt,"%3d
%-20.20s
%-20.20s
%s %s %s %s
%-11.11s
%3d\r\n",
User1.Slot_Number,User1.Name,User1.City,Month1,Day1,Month2,Day2,User1.ComputerType,User1.Total_Calls);
pl(ListIt);
Test = 0;
if(y+5 > User.Length)
{
Test=1;
y=0;
goto PROMPT;
}
y++;
}
goto NEXTFILE;
}
//********************
//***** User # *****
//********************
int UserNumber(int Slot)
{
int fd2,stat;
long Position;
char string[255];
Slot--;
Position = (LONG) Slot * sizeof(struct User);
GetStr(string,1);
strcat(string,"Accounts.data");
fd2=Open(string,MODE_OLDFILE);
if(fd2==0)
return(0);
stat = Seek(fd2,Position,0);
if(stat == -1)
{
pl("\r\n
Number to high!\r\n\r\n");
return(1);
}
Read(fd2,(char *)&User1, sizeof(struct User));
Close(fd2);
strcpy(Name,User1.Name);
return(0);
}
//*************************
//***** Display App *****
//*************************
void DisplayApp()
{
register int x;
char path[255];
//**********************
//***** Fix Name *****
//**********************
for(x=0;x<strlen(Name);x++)
{
if(Name[x]==' ' || Name[x]=='/' || Name[x]==':' || Name[x]=='?' || Name[x]=='*')
stringold[x]='_';
else
stringold[x]=Name[x];
}
stringold[x]='\0';
GetStr(path,9);
sprintf(string2,"%sApplications/%s.ans",path,stringold);
//*********************************
//***** Display Application *****
//*********************************
if(access(string2,0)==0)
{
pl("\f");
showfile(string2);
//**********************************
//***** Write Activity to Log *****
//**********************************
if( (stricmp(User.Name,Name) != 0) && (stricmp(SystemData.SysopName,User.Name) != 0) )
{
sprintf(string1,"%sSkel-NUAL.Log",SystemData.LogsPath);
sprintf(string2,"%s Viewed App of %s\n",User.Name,Name);
WriteFile(string1,string2);
}
}
}
//**************************
//***** Download All *****
//**************************
void DownloadAll(void)
{
char string1[200],string3[200],output[100],input[100],stringold[100],Name[75];
int stat,fd,x;
FILE *out,*in;
pl("\r\n
Please wait while file is created!\r\n\r\n");
sprintf(output,"NODE:DLNUAL-%d",NODE);
GetStr(string3,1);
strcat(string3,"Accounts.data");
fd=Open(string3,MODE_OLDFILE);
if(fd==0) return;
out=fopen(output,"w");
if(out==NULL) return;
NEXTFILE:
stat=Read(fd,&User1, sizeof(struct User));
if((stat<1)||(CTRLC()))
{
Close(fd);
fclose(out);
pl("
File created! Press any key to start download!\r\n");
getkey(string3);
ZmodemDownload(output);
DeleteFile(output);
return;
}
if(User1.Status==2)
{
strcpy(Name,User1.Name);
for(x=0;x<strlen(Name);x++)
{
if(Name[x]==' ' || Name[x]=='/' || Name[x]==':' || Name[x]=='?' || Name[x]=='*')
stringold[x]='_';
else
stringold[x]=Name[x];
}
stringold[x]='\0';
GetStr(string3,9);
sprintf(input,"%sApplications/%s.ans",string3,stringold);
in=fopen(input,"r");
if(in!=NULL)
{
while(fgets(string1,120,in)!=NULL)
{
if(!((string1[0]=='P')&&(string1[7]=='d')&&(string1[13]==':'))) fprintf(out,string1);
}
fprintf(out,"==============================================================================\n");
fclose(in);
}
}
goto NEXTFILE;
}
//*************************
//***** Close Stuff *****
//*************************
void CloseStuff()
{ DOOR_DATA=99; strcpy(DOOR_MSG,'\0'); DOORIO();
while(msg=(struct MyMessage *)GetMsg(MyPort)) ReplyMsg((struct Message *)msg);
if(MyPort) DeletePort(MyPort);
exit(0); }
//********************
//***** DoorIO *****
//********************
int DOORIO()
{
struct MsgPort *HisPort;
struct MyMessage message;
int UPDATE;
if(EXIT_FLAG) return 0;
UPDATE=0;
HisPort = FindPort(st);
if(HisPort!=NULL)
{
message.Msg.mn_Node.ln_Type = NT_MESSAGE;
message.Msg.mn_Length = sizeof(message);
message.Msg.mn_ReplyPort = MyPort;
if(first)CopyMem(&User,&message.User,sizeof(struct User));
message.car = 0;
message.Data = DOOR_DATA;
message.Value = DOOR_VALUE;
message.IntValue = DOOR_VALUE1;
strcpy(message.text,DOOR_MSG);
strcpy(message.text1,DOOR_MSG1);
PutMsg((struct MsgPort *)HisPort,(struct Message *)&message);
Wait(1 << MyPort->mp_SigBit);
GetMsg(MyPort);
DOOR_DATA = message.Data;
DOOR_VALUE = message.Value;
DOOR_VALUE1 = message.IntValue;
strcpy(DOOR_MSG,message.text);
strcpy(DOOR_MSG1,message.text1);
CopyMem(&message.User,&User,sizeof(struct User));
first=1;
UPDATE=0;
if(message.car) EXIT_FLAG=1;
}
return 0;
}
//************************
//***** Door Start *****
//************************
DoorStart(char node[])
{
struct MsgPort *HisPort;
EXIT_FLAG = 0;
sprintf(st,"%s:TEMPEST_DOOR",node);
HisPort = FindPort(st);
if(HisPort==NULL) return (FALSE);
sprintf(MyName,"%s:DOOR_PORT",node);
MyPort = CreatePort(MyName,0L);
if(MyPort==NULL)
{
PutStr("Cant Open port");
return(int)FALSE;
}
DOORIO();
return (int)TRUE;
}
//*********************
//***** Get Key *****
//*********************
void getkey(char character[])
{ strcpy(DOOR_MSG,'\0'); DOOR_DATA=31; DOORIO(); strcpy(character,DOOR_MSG); DROP; }
//*********************************
//***** GetStr (Get String) *****
//*********************************
void GetStr(char s[],int opt)
{ DOOR_DATA=15; DOOR_VALUE=opt; strcpy(s,'\0'); DOORIO(); strcpy(s,DOOR_MSG); }
//*******************
//***** Input *****
//*******************
void input(char mstring[],int len)
{ DOOR_DATA=40; DOOR_VALUE=len; strcpy(DOOR_MSG,mstring); DOORIO();
strcpy(mstring,DOOR_MSG); strcpy(DOOR_MSG,'\0'); strcpy(DOOR_MSG1,'\0'); DROP; }
//*****************************
//***** PL (Print Line) *****
//*****************************
void pl(char outstring[])
{ DOOR_DATA=1; strcpy(DOOR_MSG,outstring); DOORIO(); }
//***********************
//***** Show File *****
//***********************
void showfile(char mstring[])
{
FILE *fp;
char string[255],string2[255],key[50];
int x=0;
fp=fopen(mstring,"r");
if(fp!=NULL)
{
while(fgets(string,120,fp)!=NULL)
{
if(User.Slot_Number==1) goto OK;
if(!((string[0]=='P')&&(string[7]=='d')&&(string[13]==':')))
{
OK:
sprintf(string2,"%s\r",string);
pl(string2);
}
x++;
if(x>16)
{
x=0;
pl("
More
[
Y
,
n
]: ");
getkey(key);
pl("\r\n");
if((key[0]=='n')||(key[0]=='N')) { fclose(fp); return; }
}
}
}
fclose(fp);
}
//************************
//***** Write File *****
//************************
void WriteFile(char ostring[],char mstring[])
{ DOOR_DATA=16; strcpy(DOOR_MSG,ostring); strcpy(DOOR_MSG1,mstring); DOORIO();
strcpy(DOOR_MSG,'\0'); strcpy(DOOR_MSG1,'\0'); }
//*****************************
//***** Zmodem Download *****
//*****************************
// Send a file with zmodem, just send the complete path.
void ZmodemDownload(char path[])
{ DOOR_DATA=27; strcpy(DOOR_MSG,path); DOORIO(); }
//*************************
//***** CTRLC CHECK *****
//*************************
int CTRLC(void)
{
DOOR_DATA=73;
DOORIO();
return(DOOR_VALUE);
}